<!--  -->
<template>
	<view class="item-strategy">
		<view class="summary title">
			<view class="summary-title row">
				<view class="nav-wrap">
					<picker mode="selector" :range="marketArr" range-key="name" @change="changePicker"
						class="picker-box">
						<text class="strategy-name">{{market}}</text>
						<u-icon name="arrow-down" class="arrow" size="18" color="#C9C9C9"></u-icon>
					</picker>
				</view>
				<text class="strategy-status stop" @click="onAppShare">分享</text>
			</view>
		</view>
		<view class="money">
			<view class="title">总资产折合(USDT)</view>
			<view class="asset">
				<text class="amount">34.21</text>
				<text class="cny">≈￥2004242.12</text>
			</view>
		</view>
		<view class="summary">
			<view class="summary-title row">
				<text>运行中策略</text>
				<text>今日利润</text>
				<text>年化收益率</text>
				<text>累计利润</text>
			</view>
			<view class="summary-content row">
				<text>3</text>
				<text>42677</text>
				<text>30%</text>
				<text>426770</text>
			</view>
		</view>
	</view>
</template>

<script>
	import { appShare, closeAppShare } from '@/utils/shareutil';
	import {
		fakePosition,
	} from "@/api/mock/home.js";
	export default {
		data() {
			return {
				market: '',
				marketArr: [],
			};
		},

		components: {},

		computed: {},

		mounted() {
			fakePosition().then(data => {
				this.market = data.position;
				this.marketArr = data.positionArr;
			});
		},

		methods: {
			changePicker(e) {
				this.market = this.marketArr[e.detail.value];
			},
			// APP分享
			onAppShare() {
				// #ifdef APP-PLUS
				let shareObj = appShare({
					shareUrl:"http://yide.aqielife.cn/",
					shareTitle:"分享的标题",
					shareContent:"分享的描述",
					shareImg:"http://qn.kemean.cn//upload/202004/18/1587189024467w6xj18b1.jpg",
					appId : "wxd0e0881530ee4444", // 默认不传type的时候，必须传appId和appPath才会显示小程序图标
					appPath : "pages/home/home",
					appWebUrl : "http://yide.aqielife.cn/",
				},res => {
					console.log("分享成功回调",res);
					// 分享成功后关闭弹窗
					// 第一种关闭弹窗的方式
					closeAppShare();
				});
				setTimeout(() => {
					// 第二种关闭弹窗的方式
					shareObj.close();
				},5000); 
				// #endif
				// #ifndef APP-PLUS
				uni.showToast({
					title:"请在APP环境使用",
					icon:"none"
				});
				// #endif
			},
			
			//用户点击分享
			onShareAppMessage(e) {
				// wxShare方法已挂载全局
				return this.wxShare();
			}

		},
	};
</script>
<style lang='scss' scoped>
	// 我的资产
	.item-strategy {
		display: flex;
		flex-direction: column;
		background-color: #151e3d;
		border-radius: 20rpx;
		color: cornflowerblue;
		margin: 0 30rpx;
		padding: 10rpx 20rpx;

		// 资产
		.money {
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			min-height: 80rpx;

			.title {
				font-size: 20rpx;
			}

			.asset {
				display: flex;
				color: aliceblue;
				font-size: 28rpx;
				justify-content: space-between;
			}
		}

		.item-name {
			margin-bottom: 15rpx;
			font-size: 24rpx;
		}

		.summary {
			display: flex;
			flex-direction: column;
			min-height: 100rpx;
			margin-bottom: 0rpx;

			&.title {
				min-height: 60rpx;
			}

			.row {
				display: flex;
				margin-bottom: 5rpx;
				flex-direction: row;
				justify-content: space-between;

				.strategy-name {
					color: aliceblue;
				}

				.strategy-status {
					color: aqua;

					&.stop {
						color: orangered;
					}
				}

				text {
					text-align: center;
				}

				&.summary-title {
					font-size: 20rpx;
					margin: 10rpx 0 20rpx 0;
				}

				&.summary-content {
					font-size: 28rpx;
					color: aliceblue;

					text {
						display: flex;
						min-width: 80rpx;
						align-items: center;
						justify-content: center;
					}
				}
			}
		}

		.strategy-btn {
			width: 90vw;
			display: flex;
			// align-content: flex-end;
			// align-items: flex-end;
			flex-direction: row;
			justify-content: flex-end;

			.u-btn {
				margin-left: 10rpx;
				margin-right: 0;
			}
		}

		.date {
			color: aliceblue;
			margin-bottom: 10rpx;
		}
	}
</style>
